require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

useMapLibre = false

if useMapLibre
  $RNMBGL_Use_SPM = {
    url: "https://github.com/maplibre/maplibre-gl-native-distribution",
    requirement: {
      kind: "upToNextMajorVersion",
      minimumVersion: "5.11.0"
    },
    product_name: "Mapbox"
  }
end

# We ingore warning except for RNMBGL
INHIBIT_WARNING_BY_DEFAULT = true

if INHIBIT_WARNING_BY_DEFAULT
  ORIG_POD = method(:pod)

  # Override pods so we default to disbling all warnings
  def pod(name, *requirements)
    options = requirements.last
    if options.is_a?(Hash)
      options[:inhibit_warnings] = true unless options.has_key?(:inhibit_warnings)
    else
      requirements.push({inhibit_warnings: true})
    end
    ORIG_POD[name, *requirements]
  end
end

target 'RNMapboxGLExample' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  # default version
  pod 'react-native-mapbox-gl', :path => '../../', :inhibit_warnings => false

  target 'RNMapboxGLExampleTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!

  pre_install do |installer|
    $RNMBGL.pre_install(installer)
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  if !ENV['CI']
    # local configuration
    use_flipper!({ 'Flipper-Folly' => '2.3.0' })
    post_install do |installer|
      flipper_post_install(installer)
      $RNMBGL.post_install(installer)
    end
  else
    # CI configuration
    post_install do |installer|
    $RNMBGL.post_install(installer)
    end
  end
end

target 'RNMapboxGLExample-tvOS' do
  # Pods for RNMapboxGLExample-tvOS

  target 'RNMapboxGLExample-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end
